package cn.tedu.exercise;

import java.sql.*;

/**
 * @author :Colin
 * @version 创建时间: 2021/7/2 19:18
 */
public class Exercise1 {
    public static void main(String[] args) throws Exception {
        //1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取链接
        String url="jdbc:mysql://localhost:3306/colinbase";
        Connection conn = DriverManager.getConnection(url, "root", "root");
        //3.获取传输器
        Statement st = conn.createStatement();
        //4.执行sql语句
        String sql="select * from emp";
        ResultSet rs = st.executeQuery(sql);
        //5.查询结果集
        while(rs.next()){
            int empno =rs.getInt("empno");
            String ename=rs.getString("ename");
            Double comm=rs.getDouble("comm");
            System.out.println(empno+ename+comm);
        }
        rs.close();
        st.close();
        conn.close();
    }

}
